// ----------------
// import common api
// ----------------
import org.pi.common.Api._

// ----------------
// load input image
// ----------------
var im = rgb2gray(imread("data/abstrakt.png"))

// ----------------
// compute stuff
// ----------------
tic
val bin = im>0.5f
val mask = circMask(9);
val im1 = imopen(bin,mask)
val im2 = imclose(bin,mask)
toc("elapsed time")
// ----------------
// output
// ----------------
figure
// show output image
subplot(2,2,0);
imshow( bin )

subplot(2,2,1);
imshow( mask )

subplot(2,2,2);
imshow( im1 )

subplot(2,2,3);
imshow( im2 )

/*
output (4x):
elapsed time: 2032 ms.
elapsed time: 2219 ms.
elapsed time: 2422 ms.
elapsed time: 2000 ms.
*/
